import wjRequest from '@/service'
import type { IDataType } from '@/service/types'

/**
 * 获取数据
 * @param url {string}   /user/list
 * @param queryInfo {object}
 * @returns
 */
export function getPageListData(url: string, queryInfo: any) {
  return wjRequest.post<IDataType>({
    url: url,
    data: queryInfo
  })
}

/**
 * 删除数据
 * @param url {string}  /user/:id
 * @returns
 */
export function deletePageData(url: string) {
  return wjRequest.delete<IDataType>({
    url
  })
}

/**
 * 创建
 * @param url {string}
 * @param newData {object}
 * @returns
 */
export function createPageData(url: string, newData: any) {
  return wjRequest.post<IDataType>({
    url: url,
    data: newData
  })
}

/**
 * 编辑
 * @param url {string}
 * @param newData {object}
 * @returns
 */
export function editPageData(url: string, newData: any) {
  return wjRequest.patch<IDataType>({
    url: url,
    data: newData
  })
}
